package net.lijingye.education.vo;

import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.serializer.SerializerFeature;
import net.lijingye.education.entity.Topic;
import net.lijingye.education.util.CommonUtil;

import java.util.Date;

/**
 * Created by LijingYe on 2016/3/26.
 */
public class TopicLiteVO {
    @JSONField(name = "id", ordinal = 0, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private String id;
    @JSONField(name = "type", ordinal = 1, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private String type;
    @JSONField(name = "lesson", ordinal = 2, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private String lesson;
    @JSONField(name = "title", ordinal = 3, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private String title;
    @JSONField(name = "isSolved", ordinal = 4, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private Boolean isSolved;
    @JSONField(name = "time", ordinal = 5, serialzeFeatures = SerializerFeature.WriteMapNullValue, format = "yyyy/MM/dd HH:mm")
    private Date time;
    @JSONField(name = "author", ordinal = 6, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private String author;
    @JSONField(name = "brief", ordinal = 7, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private String brief;
    @JSONField(name = "kickTime", ordinal = 8, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private Integer kickTime;
    @JSONField(name = "replyCount", ordinal = 9, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private Integer replyCount;

    public TopicLiteVO(Topic topic){
        this.id = String.valueOf(topic.getId());
        this.type = CommonUtil.getTopicTypeText(topic);
        this.lesson = topic.getLesson().getCourse().getName();
        this.title = topic.getTitle();
        this.isSolved = CommonUtil.getTopicIsSolvedBoolean(topic);
        this.time = topic.getTime();
        this.author = CommonUtil.getUserDisplayName(topic.getAuthor());
        this.brief = CommonUtil.getBriefText(topic.getContent());
        this.kickTime = topic.getKickTime();
        this.replyCount = topic.getTopicReplyList().size();
    }

    public TopicLiteVO(String id, String type, String lesson, String title, Boolean isSolved, Date time, String author, String brief, Integer kickTime, Integer replyCount) {
        this.id = id;
        this.type = type;
        this.lesson = lesson;
        this.title = title;
        this.isSolved = isSolved;
        this.time = time;
        this.author = author;
        this.brief = brief;
        this.kickTime = kickTime;
        this.replyCount = replyCount;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getLesson() {
        return lesson;
    }

    public void setLesson(String lesson) {
        this.lesson = lesson;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public Boolean getSolved() {
        return isSolved;
    }

    public void setSolved(Boolean solved) {
        isSolved = solved;
    }

    public Date getTime() {
        return time;
    }

    public void setTime(Date time) {
        this.time = time;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public String getBrief() {
        return brief;
    }

    public void setBrief(String brief) {
        this.brief = brief;
    }

    public Integer getKickTime() {
        return kickTime;
    }

    public void setKickTime(Integer kickTime) {
        this.kickTime = kickTime;
    }

    public Integer getReplyCount() {
        return replyCount;
    }

    public void setReplyCount(Integer replyCount) {
        this.replyCount = replyCount;
    }

    @Override
    public String toString() {
        return "TopicLiteVO{" +
                "id='" + id + '\'' +
                ", type='" + type + '\'' +
                ", lesson='" + lesson + '\'' +
                ", title='" + title + '\'' +
                ", isSolved=" + isSolved +
                ", time=" + time +
                ", author='" + author + '\'' +
                ", brief='" + brief + '\'' +
                ", kickTime=" + kickTime +
                ", replyCount=" + replyCount +
                '}';
    }
}
